#include "queryPlayRecordMessageHandler.h"
#include "queryPlayRecordMessage.h"
#include "httpJsonClient.h"
#include "queryPlayRecordResMessage.h"

void QueryPlayRecordMessageHandler::handle(MtpMessage* message, const IPaddress& attachment)
{
	HttpJsonClient client;
	client.get("operation/playRecords/playing");
	if (!client.requestSuccess()) {
		throw AppException(client.getErrorMessage().c_str());
	}
	QueryPlayRecordResMessage msg(message);
	msg.fromJson(client.getResponse());
	msg.send(attachment);
}

MtpMessage* QueryPlayRecordMessageHandler::decode(MtpProtocol* packet, const IPaddress& attachment)
{
    return new QueryPlayRecordMessage(packet);
}
